package com.DIInject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @Author Fizz Pu
 * @Date 2021/5/5 下午7:53
 * @Version 1.0
 * 失之毫厘，缪之千里！
 */
public class DIINjectTest {

}


@Component
class TestService{
    public int a = 100; // 可以从配置文件注入

    /*@Autowired 值的注入
    public TestService(int a){
        this.a = a;
    }*/

    @Override
    public String toString() {
        return "TestService{" +
                "a=" + a +
                '}';
    }
}

@Component
class Dependcy {

    public Dependcy(){

    }

    @Autowired
    public Dependcy(TestService testService){
        this.testService = testService;
    }

    public TestService testService;

}
